<?php
namespace app\common\model;

class MemberInviter extends Base
{
    /**
	 * 根据层级查找推荐人
	 * @param  [type] $floor [description]
	 * @return [type]        [description]
	 */
	public function getInviter($uid,$floor=0){
		$inviter_uid = $this->where(['uid'=>$uid,'floor'=>$floor])->value('inviter_uid');
		if(!$inviter_uid){
			return false;
		}else{
			return $inviter_uid;
		}
	}

	/**
     * 获取用户的所有安置人
     * @param  [type] $uid [description]
     * @return [type]      [description]
     */
    public function getInvitersByUid($uid){
        $data = $this->where(['uid'=>$uid])->select();
        if($data){
            foreach($data as &$value):
                $value = $value->toArray();
            endforeach;
        }
        return $data;
    }

    public function getDatas($where){
        $data = $this->where($where)->select();
        if($data){
            foreach($data as &$value):
                $value=$value->toArray();
            endforeach;
        }
        return $data;
    }


}
